package com.woniu.woniuticket.controller;


import com.woniu.woniuticket.entity.Movie;
import com.woniu.woniuticket.service.IMovieService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.List;


import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Lucas
 * @since 2020-02-18
 */
@Controller
//@RequestMapping("/movie")
@CrossOrigin("*")
public class MovieController {

    @Resource
    private IMovieService iMovieService;

    @RequestMapping("findallmovie")
    @ResponseBody
    public List getMovie(HttpSession session, ModelMap modelMap){
        List<Movie> movie=iMovieService.findAll();
        System.out.println(movie);
        System.out.println("================");
        modelMap.put("findmovie",movie);
        return movie;
    }


    @RequestMapping("findByIdmovie")
    @ResponseBody
    public List getMovieInfo(HttpSession session,Integer movieId,ModelMap modelMap){

        List<Movie>  movie2=iMovieService.findInfoById(movieId);
        System.out.println(movie2);
        modelMap.put("moid",movie2);

        return movie2;
    }

    @RequestMapping("findmovietime")
    @ResponseBody
    public List getMovietime(Integer movieId){

        List<Movie> movie=iMovieService.findtime(movieId);

        System.out.println(movie);

        return movie;
    }

//    @RequestMapping("findmovietime")
//    @ResponseBody
//    public List getMovietime(){
//
//        List<Movie> movie=iMovieService.findtime();
//
//        System.out.println(movie);
//
//        return movie;
//    }

    @RequestMapping("findalltime")
    @ResponseBody
    public List getMoviealltime(Integer movieId){
        System.out.println("id"+movieId);
        List<Movie> movie=iMovieService.findalltime(movieId);
        for(int i = 0 ; i < movie.size();i++){
            System.out.println("1:"+movie.get(i));
        }
        return movie;
    }

}

